<?php

namespace app\Backend\controller;

use think\Controller;
use think\Request;
use app\common\model\Setting as SettingModel;

class Setting extends Controller
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $setting = SettingModel::all();
        return view('', compact('setting'));
    }


    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        $settingModel = new SettingModel();
        $data = $request->post();
        foreach ($data as $key => $value) {
            $settingModel->where('c_name', $key)->update(['c_value'=>$value]);
        }
        $this->success('保存成功！');
    }
}
